package com.alibaba.cloud.ai.example.graph.basic_chatbot;

import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.model.ChatResponse;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Flux;

@Service
public class BasicChatBotService {
    private final ChatClient chatClient;

    public BasicChatBotService(ChatClient.Builder chatClientBuilder) {

        this.chatClient = chatClientBuilder
                .defaultSystem("You are a helpful AI Assistant answering questions.")
                .build();
    }

    public Flux<ChatResponse> execute(String input) {
        return chatClient
                .prompt()
                .user(input)
                .stream()
                .chatResponse();
    }
}